package com.ruoyi.web.petmall.petback.service.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.petmall.entity.AddressEntity;
import com.ruoyi.web.petmall.entity.UserEntity;
import com.ruoyi.web.petmall.petback.mapper.AddressMapper;
import com.ruoyi.web.petmall.petback.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    private AddressMapper addressMapper;

    /**
     * 获取地址列表
     * @param addressEntity
     * @return
     */
    @Override
    public List<AddressEntity> getAddressList(AddressEntity addressEntity) {

        return addressMapper.getAddressList(addressEntity);
    }

    /**
     * 修改地址
     * @param addressEntity
     * @return
     */
    @Override
    public int updateAddress(AddressEntity addressEntity) {

        if (Objects.isNull(addressEntity)) {
            throw new IllegalArgumentException("没有进行修改");
        }
      
        return addressMapper.updateAddress(addressEntity);
    }

    /**
     * 删除地址
     * @param id
     * @return
     */
    @Override
    public int deleteAddress(Long id) {
        if (Objects.nonNull(id)) {
            throw new IllegalArgumentException("数据为空");
        }
        return addressMapper.deleteAddress(id);
    }
}
